import request from '../utils/request'
import API from './constants'

/**
 * 分页获取医生数据
 * @returns
 */
export const getDoctors = ({page = 1, pageSize = 10, ...conditions} = {}) => request({
  url: API.DOCTOR_API,
  method: 'GET',
  params: {
    page,
    pageSize,
    ...conditions,
  },
})

/**
 * 根据 id 获取医生信息
 * @param {*} id
 * @returns
 */
export const getDoctorById = id => request({
  url: API.DOCTOR_API + '/' + id,
  method: 'GET',
})

/**
 * 添加新医生信息
 * @param {*} doctor
 * @returns
 */
export const addDoctor = doctor => request({
  url: API.DOCTOR_API,
  method: 'POST',
  data: doctor,
})

/**
 * 更新医生信息
 * @param {*} doctor
 * @returns
 */
export const updateDoctor = doctor => request({
  url: API.DOCTOR_API + '/' + doctor.get('id'),
  method: 'POST',
  data: doctor,
})

/**
 * 根据 id 删除医生信息
 * @param {*} id
 * @returns
 */
export const removeDoctor = id => request({
  url: API.DOCTOR_API + '/' + id,
  method: 'POST',
})
